Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

whatwg-url

Package Overview
Dependencies
Maintainers
6
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whatwg-url

An implementation of the WHATWG URL Standard's URL API and parsing machinery

  • 12.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created

What is whatwg-url?

The whatwg-url npm package is an implementation of the URL and URLSearchParams interfaces found in the WHATWG URL Standard. It provides utilities for URL parsing, serialization, and manipulation in accordance with the standard.

What are whatwg-url's main functionalities?

Parsing and Serializing URLs

This feature allows for the parsing of a full URL string into its constituent parts, as well as the serialization of the URL object back into a string.

const { URL } = require('whatwg-url');
const myURL = new URL('https://example.com/path?query=123#fragment');
console.log(myURL.href); // 'https://example.com/path?query=123#fragment'

Manipulating URL Components

This feature enables the modification of different parts of the URL, such as the pathname, search, or hash.

const { URL } = require('whatwg-url');
const myURL = new URL('https://example.com/path');
myURL.pathname = '/newPath';
console.log(myURL.href); // 'https://example.com/newPath'

Working with URLSearchParams

This feature provides an interface for working with query strings, allowing for easy parsing, appending, deleting, and iterating over query parameters.

const { URLSearchParams } = require('whatwg-url');
const params = new URLSearchParams('key1=value1&key2=value2');
params.append('key3', 'value3');
console.log(params.toString()); // 'key1=value1&key2=value2&key3=value3'

Other packages similar to whatwg-url

FAQs

Package last updated on 08 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc